package dynamicprogramming.爬楼梯;

public class Solution {
    public int climbStairs(int n) {
        /**
         * f(n) = f(n-1) + f(n-2)
         * 初始值： f(1) f(2) = 2
         */
        int[] ans = new int[n];
        ans[1] = 1;
        ans[2] = 2;
        for (int i = 2; i < n ; i++) {
            ans[i] = ans[i-1] + ans[i-2];
        }
        return ans[n - 1];
    }
}
